﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page
{
    BLLUser bllUser = new BLLUser();
    protected void Page_Load(object sender, EventArgs e)
    {
        HtmlControl divMain = (HtmlControl)Page.Master.FindControl("divMain");
        divMain.Attributes.Add("style", "background:none");
        HtmlControl divMainContent = (HtmlControl)Page.Master.FindControl("divMainContent");
        divMainContent.Attributes.Add("class", "main-content-login");
        HtmlControl divMainNavigation = (HtmlControl)Page.Master.FindControl("divMainNavigation");
        divMainNavigation.Visible = false;
        HtmlControl divHeaderBottom = (HtmlControl)Page.Master.FindControl("divHeaderBottom");
        divHeaderBottom.Visible = false;
        HtmlControl divHeaderBreadcrumbs = (HtmlControl)Page.Master.FindControl("divHeaderBreadcrumbs");
        divHeaderBreadcrumbs.Visible = false;
        LinkButton lnkLogout = (LinkButton)Page.Master.FindControl("lnkLogout");
        lnkLogout.Visible = false;
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            this.lblError.Visible = false;
            string msg = "";
            bool result = bllUser.AuthenticateUser(this.txtUsername.Text.Trim(), this.txtPassword.Text.Trim(), out msg);
            if (!result)
            {
                this.lblError.Text = msg;
                this.lblError.Visible = true;
            }
            else
            {
                if (Request["redirectUrl"] != null)
                    Response.Redirect(Server.UrlDecode(Request["redirectUrl"]), false);
                else
                    this.Response.Redirect("~/Configuracion/Productos/", false);
            }
        }
        catch 
        {
            
        }
    }
}